package com.example.animationlearn;

import androidx.appcompat.app.AppCompatActivity;

import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Process;
import android.widget.RemoteViews;
import android.widget.Toast;

import java.util.Date;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        RemoteViews views = new RemoteViews(getPackageName(), R.layout.layout_simulated_notification);
        views.setImageViewResource(R.id.imageView, R.drawable.ic_launcher_background);
        views.setTextColor(R.id.textView, Color.RED);
        views.setTextViewText(R.id.textView, "my progress:" + Process.myPid());
        int requestId = (int) new Date().getTime();
        PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, requestId,
                new Intent(MainActivity.this, NotificationActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
        views.setOnClickPendingIntent(R.id.textView, pendingIntent);
        Intent intent = new Intent("com.ssy.myintnent.action");
        intent.putExtra("com.ssy.myintnent.remoteview", views);
        sendBroadcast(intent);
        Toast.makeText(this, "--", Toast.LENGTH_SHORT).show();

//        findViewById(R.id.startButton).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                TextView tv = findViewById(R.id.tv);
//                Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotateanim);
//                tv.startAnimation(animation);
//            }
//        });
    }
}
